package com.test.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.test.cmn.mapper.DictMapper;
import com.test.model.cmn.Dict;
import com.test.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;


/**
 * @date 2021/7/29 -11:27
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

    public DictMapper dictMapper;

    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    /**
     * 逐行读取数据，第二行开始
     * @param dictEeVo
     * @param analysisContext
     */
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo,dict);
        System.out.println(dict.toString());
        dict.setIsDeleted(0);
        dictMapper.insert(dict);
    }

    /**
     * 读取后执行
     * @param analysisContext
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}

